package com.haima.sage.bigdata.api.frame.condition.impl;

import java.util.Map;

import com.haima.sage.bigdata.api.frame.condition.ConditionItem;
import com.haima.sage.bigdata.api.frame.condition.expression.LogicService;
import com.haima.sage.bigdata.api.frame.condition.expression.LogicServiceFactory;

public class ConditionItemService extends ConditionService<ConditionItem> {
    private LogicService logicService;
    public ConditionItemService(ConditionItem condition) {
        super(condition);
        this.logicService = LogicServiceFactory.getInstance(config.getOperator(), config.getValue());
    }

    @Override
    public boolean deal(Map<?, ?> event) throws Exception {
        Object value = event.get(config.getField());
        return logicService.logic(value);
    }

    @Override
    public boolean deal(String raw) throws Exception {
        return logicService.logic(raw);
    }
}
